up max statements from 15 to 16
rename variable 'Promise' to 'When'
abstract inner set of conditonals to handleData function to reduce nesting