added logic to center viewport