added input protection