rewritten code (v2.0)

completely rewritten version
updated readme