cleaned up with some comments