Added console logs. Fixed closure issue.