Refactoring code, simplifying