Moved database queries from controllers to models