add sleep and clarify defer in api doc