refactors final prompt element into function