style
style: optimize if-statement and assignment