refactored ifelse to padded logic