making some tweaks which fixed the code