cleaned up and commented