split up func def and return logic