committing polished version of working routines