fixed bound check for width