Object oriented code refactor