Add refacted logic for login helpermethod