yet another attempt + style improvements