refactored isOutOfBounds to use a ternary operator