New implementaion of Danieles code