Use assign instead of 6 lines of conditions