Updated SelectPath.java with inserting condition

added if