data structure and codes modified to suit database changes