migrated to amd pattern
oops added lib
phew! removed circular dependencies