Simplifies endpoint calculation
bugfix2