Added first few lines. A bit a pseudocode