fix bound check