allowed for multiple error messages and customised error messages
minor modification