fixed bugs in wrapper