implemented customised distance state thingo