fixed viewing/inserting to database