fixed returning of local variables