Changed code based on comments from daira on 6900bf4