fixed small bug while calculation y_offset