cleanup and logging for login func