CHANGED:clean code and logging somehow