Additional check to prevent script freeze