improved dynamo writing code