added code for appending to binary matrix