incomplete code for database write