refactored legacy calls to use generators
using elif instead of else