Refactored business logic; reimplemented in idiomatic object oriented way