DRY and removed unused code
Add memory for start and end points