calculating start/end from pos & length