fixing save to database bug