all code implemented but still needs debugging