confirmed functionality, removed console.logs