simplify code based on @stasm feedback