Adjusted and added code