#79 Refactor code