Making init script more intelligent