adding new logic from testing-branch