added input errors, also added guard