changing logic to models from controllers