fix a bug with trailing and leading spaces