use if-else to avoid doing too much work