improved return statements and local scoping