finished basic logic, but still not correct.