Refactored get returned_type to have only one if