updated with the latest codes