adapted code for customizing size and speed