6th commit - another bugs fixing attempt

deploy function small recoding. still not fixed yet.