use return instead of big if-else