Refactored to return consistent data type