made code work in console. length needs to be normalized.