Tested

Tested and fixed code