Added logging and security