new function with some correction