added statements to if, not sure about firstval