Clean up function from SO and "use strict" everywhwere