Fixed a bug in code