Optimized script for gravel and better performance