removed some of the puts, but will have to optimize the code