Added an if statement to center function to prevent larger sized elements getting pushed to the top