move error messages to functions

Signed-off-by: Blessing Osakue <iyoworks@gmail.com>