added logging and testing