Added locking to timer