Refactored and made login take arguments