some changes to make it work in emulator