removed prints and cleaned up code