tested and working perfectly
removed redundancy