Rewrote in bash