adds logging and fixed stopping