added volatile stuff so that compiler doesn't optimize stuff out