correcting some bugs. Now working.