fixed bugs, still one bug left though :/