changed bin detect as suggested