sliding logic made more generic and events done