optimized checkPy and removed test code