optimise, ifs to assigns