Some refactoring and added isInBound() validation method.