changed if/else flow