updated code example (may be still to large)