Modified code, fixed a bug