line rendering script is now a bit more robust