fixed bug and updated output