using timer instead of a wait loop