HW4 forward search code