bugfixing and restoring original functions