Updated code with new features aka logout, logging