Fixed Error in Order of Execution

This way, query is not executed at all if username contains invalid
chars.