refactor find slot code into a class