fixed loop issues
refactor code for command filter in client