how sleep affects pain