moved some stuff around. added some comments