Move logic to models/controller