Refactor code and create todo to methods #1