added support for arbitary return types and simpler construction