working version
Added corresponding Tests and Comments