algorithm and testing the state goais
--