some improvement to loader.py