reordered code for easier reading
let