Done with HW4 but buggy