added some more code still need to work out some bugs