Fix bug in code