improved slot function