improve use of constants and generator