added trim method to js for adding items