further improvements and a bug fix for the  not being correctly passed