pytho code implemented, need to fix bugs