Refactoring code

Code is now self-explanatory