Remove similar code to improve code climate