restored web worker support and added window check