This code is not good. refactoring it now.