moved some functions around