created basic function to identify possible paths through a given matrix