refactory database status code