Refactoring client side code for best practise.