Implemented @keflavich's comments