reorganized the code :D