a generic scheduler