Added boundary checks to at, col and row