Added element centering function