added functionality and tests