corrected bug in code