added sign in feature, code also refactored