Major refactor I ~login function + errorHandling + helper