few semplification and input removed