adding implementation and tests