Changed parameters and added logging