add checks to fix common bugs