changed controller function
changed loop, rewrited main logic
changed limit time for test
optimized array emptying