simplify logic with maybe fun