updated functionality and tests