streamlined some of the code, placed parseCircuits into one whole
function and implemented priority queue for Dijkstras