added logging and a single insert