comments. cleaned up code structure