Fixed bug in code