updated to chris's code