refactoring and adding hlint pragmas