cleaning up code, added profiler