now works 2 modes of execution
some changes