Harden code with user error checking