[ailyasov] add boundary check