modified checkReturnDeclaration-function