cleaned up db queries