fixed chaining and added test