Take into account the return type

In case the return type was void, the code was not working.