updated code to 1.8 (needs bug testing)