implemented priority scheduling