Fixed saving to database