works -needs tidying