implemented timer, a little buggy