Simplify code of type conversion