Decoupled code

This code does the same in a more maintainable and cleaner way. 
High possibility of new bugs.