Solving type error