now writes to all necessary tables in database and front end works