fixed up bind and cleaned up implementation