Changed use of endValue to be less complex and pass JShint