Add explicit type conversion to avoid runtime error