improve code, remove need for second script