added filter and rest detection