fixed possible overflow in context