more validation. ugly code though.