added end condition to bind