fix class and further improve load function