Optimize & refactoring code for scrutinizr