now works properly in simulator