updated database functions and added better record manipulation