cleaned up & commented code
fixed compliation error