Added login logic and finished Problem to Function model refactor