404 when objects not found on database (replaces flask-sqlalch function)