refacotred to accept context
dropeed py3.2 support