fixing incorrect height when dir is set to -1