middle of adapting code from mike h to make project work