updated code to phython 3 + tested