Updated code to match original combined with new