working correctly on examples