Refactored rotator js a bit