#155 Refactor code