weekend work, will be finished in next commit