"Standard solution" is to use a timer. You're currently using a non-standard one