added waitfor after every new resource has been loaded