Fix return value check