This code is not mine. It's from  I've commit just for studying.