simplify backend code

Use either function instead case of statement.