fixed bug in code