improving authentication code (tidyup).