state diagram
almost done only the outputs need to be connected