Moved "logic" functionality to a separate module