bug fixed;start implementing state machine