* changed bitwise & to logical && * removed redundant state check * moved a strcpy inside a NULL check to prevent a crash. NOTE: nothing sensible will happen as a result, but no crash at least.