fixing loading code