second attempt at fixing bugs