solved lust but one bug in the code