some minor changes to clean up code and remove redundent lines