Simplified code to handle stalling (also made it actually accurate)