Trying to solve the bug, no success yet, solved a small problem in the code though