fixed bug. cleaned up code