Fixed a bug in the existing code.