initial implementation in Python