Refactor to improve centring code