Improved codebox script