added working algorithm
added generic place