added sign in functionality and optimize exist_in function