functions need fixing. see failed tests