Cleaner database code