removed debugging puts statements and refactored one line