cleaned up a bit and added explanation