fix error returning function routine