moved some code between modules