cleaned up and comments added