genTopX function added to manage_db