patched code a tiny bit