Small changes to code. Use item function