Removed redundant code and fixed login function return value