Fixed small bug with getting the end