Insert data into database properly