fix wrong input and use input dimension