Fix scale logic and add sprintf function to clean up variables in strings