merge toien's code