fixed bugs, now working.