added safety for pos checking
added flexibility to recurse methods