added code and adjustments 4