modified my h_sync to have my state logic and output logic