consolidated to one database table and refactored code