removed time to center, refactored code