fix bug in function to get center of view