How to prevent maximum execution time on my code