Solves 1.1 and 1.2, needs refactoring