Client side: code refactoring