fixed bugs, seems to be working properly now...