logic improved and added disable function