updated to work as module