adaptapting the example from manstis