Edited after forke by ilaiya