adding check for err in basecontroller