fixed retrieval routines and included test routine