implemented a simple version, need gui to test
made some modifications