import code from my graduation project (2011.6.23)