Some smart refactoring!