refactoring and fixing syntax on auto_scaling handler.