changed from the hacky setTimeout model to properly using the callback