refactor the bind logic