fixed a pretty horrible bug