added (yet to check) type annotations debugged a big