Better shell function, fix formatting