Incorporating Tom's shift code