wip
fixed some problems
added some comments