ak fixed bug and beautified code