added if statement for checking states