Moved logic from controllers to data helpers