Refactor code slightly as lint recommends