refactor and add code climate