fixing deadline algorithm