made lots of changes. used facade design pattern. code stable