refactor slot calculation