fixed logic with schduling
merged changes from github