thought of another corner case. cleaned up code