fixed code to work with facebook chat