cleaning up and slight modifications