formin's basic algorithm

Signed-off-by: Friker <viktor.tomkovic@gmail.com>