Refactored timer. hopefully working for iphone...?