Better handling for db