Improved bot speed code