fix bug in code