added sparse functionality