fixes logic in getPath function to return first detected class