added comments and added another grid
refactored checking val method