added error messages and flexibility