fixed dependency checking in the main loop