added many functionality and tests